#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	if (n == 0) {
		cout << 0 << '\n';
		return;
	}

	vector<ll> dp(n + 2, 0);

	for (int i = 2; i <= n + 1; i++) {
		ll score1 = dp[i - 1];

		ll score2 = (ll) a[i - 2] + dp[i - 2];

		dp[i] = max(score1, score2);
	}

	cout << dp[n + 1] << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}